package cn.bugDance.domain.strategy.repository;

import cn.bugDance.domain.strategy.model.entity.*;
import cn.bugDance.domain.strategy.model.valobj.StrategyDelayJobQueueData;
import javafx.util.Pair;

import java.util.Date;
import java.util.List;
import java.util.Map;


public interface IStrategyRepository {
    StrategyEntity queryStrategyByStrategyId(Long strategyId);

    List<StrategyAwardEntity> queryStrategyAwardByStrategyId(Long strategyId);

    RuleConfigEntity queryRuleConfigRule(Long strategyId, String ruleWeight);

    void storeToCache(List<Integer> rateTable, long rateRangeSum, String cacheRateTableKey, String cacheRateLevelKey);

    void storeAwardCount(String cacheAwardCountKey, Integer awardCount, Long strategyId, Integer awardId, Date endTime);

    Long queryCacheRateRange(String cacheRateLevelKey);

    Integer randomRaffle(int i, String cacheRateTableKey);

    RuleTreeEntity queryRuleTreeByStrategyId(Long strategyId);

    RuleTreeEntity queryRuleTreeByStrategyIdFromCache(Long strategyId);

    List<RuleTreeNodeEntity> queryRuleTreeNodeByStrategyId(Long strategyId);

    void cacheRuleTree(RuleTreeEntity ruleTreeEntity);

    List<RuleTreeLineEntity> queryRuleTreeLineEntityByNodeFromAndStrategyId(Long nodeId, Long strategyId);

    RuleConfigEntity queryRuleConfigRuleAward(Long strategyId, Integer awardId, String ruleLock);

    StrategyAwardEntity queryStrategyAwardByStrategyIdAndAwardId(Long strategyId, Integer awardId);

    boolean strategyAwardSubtractionQuota(Long strategyId, Integer awardId, Date endDateTime);

    void sendAndProcessJobQueue(Long strategyId, Integer award);

    StrategyDelayJobQueueData takeStrategyJobQueue();

    void strategyAwardSubtractionQuotaDataBase(Long strategyId, Integer awardId);

    Integer queryAwardRuleLockValue(Long strategyId, Integer awardId);

    void storeToCacheOn(Map<AwardRateRangeEntity, Integer> rateTable, Integer sum, String cacheRateTableKey, String cacheRateLevelKey);

    Integer queryCacheRateRangeOn(String cacheRateLevelKey);

    Integer randomRaffleOn(int i, String cacheRateTableKey);

    Integer queryRateTableLen(String cacheRateTableKey);

    Map<AwardRateRangeEntity, Integer> queryCacheRateMap(String cacheRateTableKey);

    AwardRateRangeEntity algorithmQueryThreadSearch(List<AwardRateRangeEntity> awardRateRangeEntities, int random);
}
